package com.sky.local_ads.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.sky.local_ads.utils.Utils;
import com.sky.local_ads.widget.MapWrapperLayout;
import com.sky.trueoffers.R;

public class BusinessMapFragment extends Fragment {
	private MapWrapperLayout mapWrapperLayout;
	private SupportMapFragment mapFragment;
	private GoogleMap googleMap;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = null;
		if (container != null) {
			if (container.getChildCount() == 0) {
				view = inflater.inflate(R.layout.fragment_business_map,
						container, false);
				mapWrapperLayout = (MapWrapperLayout) view
						.findViewById(R.id.mapRelativeLayout);
				return view;
			} else {
				mapWrapperLayout = (MapWrapperLayout) container.getChildAt(0)
						.findViewById(R.id.mapRelativeLayout);
				return container.getChildAt(0);
			}

		}
		return view;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		int playServiceStatus=Utils.getPlayServiceStatus(getActivity());
	    if(playServiceStatus == ConnectionResult.SUCCESS) {
			FragmentManager fm = getFragmentManager();
			mapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map);
			if (mapFragment == null) {
				mapFragment = SupportMapFragment.newInstance();;
			}
			googleMap = mapFragment.getMap();
			googleMap.getUiSettings().setZoomControlsEnabled(false);
	}

	}
}
